package crmdna.payment;

import paypalnvp.core.PayPal.Environment;

public class Response {

	public String ack;
	
	public Response(String ack) {		
		this.ack = ack;
	}
	
	public String get(String token, Environment env) {
		StringBuilder sb = new StringBuilder(512);
		
		sb.append("{");
		sb.append("\"status\": \"" + ack + "\",");
		sb.append("\"redirectUrl\": " + 
				  "\"https://www." + ((env == Environment.SANDBOX) ? "sandbox." : "") + 
				  "paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + token + "\"");
		sb.append("}");
		
		return sb.toString();	
	}

	public String get(String itemName, String invoiceNumber, String txnId, String amt, String paymentStatus, String pendingReason) {
		StringBuilder sb = new StringBuilder(512);
		
		sb.append("{");
		sb.append("\"status\": \"" + ack + "\", ");
		sb.append("\"ItemName\": \"" + itemName  + "\", ");
		sb.append("\"InvoiceNumber\": \"" + invoiceNumber + "\", ");
		sb.append("\"TxnId\": \"" + txnId + "\", ");
		sb.append("\"Amount\": \"" + amt + "\", ");
		sb.append("\"PaymentStatus\": \"" + paymentStatus + "\", ");
		sb.append("\"PendingReason\": \"" + pendingReason + "\"");
		sb.append("}");
		
		return sb.toString();	
	}

	public String get(String severity, String error, String shortMsg, String longMsg) {
		StringBuilder sb = new StringBuilder(512);
		sb.append("{ ");
		sb.append("\"status\": \"" + ack + "\",");		
		sb.append("\"error\": { ");
		sb.append("\"severity\": \"" + severity + "\",");
		sb.append("\"error\": \"" + error + "\",");
		sb.append("\"shortMsg\": \"" + shortMsg + "\",");
		sb.append("\"longMsg\": \"" + longMsg + "\"");
		sb.append("}");
		sb.append("}");
		return sb.toString();		
	}
	
}
